package net.optix.ip.commands
{
	import com.adobe.cairngorm.business.Responder;
	import com.adobe.cairngorm.commands.Command;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.adobe.cairngorm.control.CairngormEventDispatcher;
	
	import net.optix.ip.business.*;
	import net.optix.ip.events.GetInventionEvent;
	import net.optix.ip.events.RenewalFeeEvent;
	import net.optix.ip.model.ModelLocator;
	
	public class RenewalFeeCommand implements Command, Responder
	{
		// attributes ============================
		private var model : ModelLocator = ModelLocator.getInstance();


		// functions ============================
		public function execute( event:CairngormEvent ) : void
		{
			var myEvent:RenewalFeeEvent = RenewalFeeEvent( event );
			
			var delegate:InventionDelegate = new InventionDelegate(  );     
			delegate.renewalFee( this , myEvent.vo );
			
		}
		
		//----------------------------------------------------------------------------
		public function onResult( event : * = null ) : void
		{
			var result:int	;
			try
			{
				result	=	event.result.result;
			}
			catch(error:Error){}
			
			switch(result)
			{
				case -2:
					model.result	=	"Access Denied !";
					break;
				case 1:
					model.result	=	"Successfully save !";
					model.close		=	"no";
					model.close		=	"yes";
					var getInvention:GetInventionEvent	=	
						new GetInventionEvent(model.currentInvention.inventionID);
					com.adobe.cairngorm.control.CairngormEventDispatcher.getInstance().dispatchEvent(getInvention);
					break;
				case 0:
					model.result	=	"Program error !";
					break;
			}
		}
		
		//----------------------------------------------------------------------------
		public function onFault( event : * = null ) : void
		{
			model.result	=	"Program error !";	
			model.bSubmit	=	true;
		}

	}
}